import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { Language } from "../../../../extend/language/Language";
import { GTextInput } from "../../../../com/mui/controls/GTextInput";
import { MsgManager } from "../../manager/MsgManager";
import { LockInfoData } from "./LockInfoData";
//class SetPasswordSprite
    
    export  class SetPasswordSprite /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ObjCreate.createBg(10, 220, 280, 2, this, ImagesConst.SplitLine);
            this._tips1Txt = ObjCreate.createTextField("", 10, 30, 300, 20, this);
            this._tips1Txt.htmlText = Language.getString(35525);
            this._tips1Txt.filters = [];
            var loc2=ObjCreate.createTextField("", 10, 120, 300, 20, this);
            loc2.htmlText = Language.getString(35526);
            loc2.filters = [];
            this._firstPwTxt = ObjCreate.createGTextInput(70, 60, 200, 20, this);
            this._firstPwTxt.maxChars = 9;
            this._firstPwTxt.restrict = "0-9";
            this._firstPwTxt.displayAsPassword = true;
            this._firstPwTxt.addEventListener(flash.events.FocusEvent.FOCUS_IN, this.onTextfieldFocusHandler);
            this._secondPwTxt = ObjCreate.createGTextInput(70, 160, 200, 20, this);
            this._secondPwTxt.maxChars = 9;
            this._secondPwTxt.restrict = "0-9";
            this._secondPwTxt.displayAsPassword = true;
            this._secondPwTxt.addEventListener(flash.events.FocusEvent.FOCUS_IN, this.onTextfieldFocusHandler);
            this._focusInTxt = this._firstPwTxt;
            var loc3=ObjCreate.createTextField("", 60, 235, 300, 20, this);
            loc3.htmlText = Language.getString(35527);
            loc3.filters = [];
            return;
        }

        /* internal  */onTextfieldFocusHandler(arg1: Object /* flash.events.FocusEvent */): void
        {
            this._focusInTxt = arg1.currentTarget as GTextInput;
            return;
        }

        public setPassword(): Boolean
        {
            var loc1=false;
            if (this._secondPwTxt.text == this._firstPwTxt.text) 
            {
                if (this._firstPwTxt.text.length < 5) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(35529));
                }
                else if (this._firstPwTxt.text.length > 9) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(35530));
                }
                else if (this._firstPwTxt.text != "") 
                {
                    if (this._secondPwTxt.text != "") 
                    {
                        LockInfoData.password = this._firstPwTxt.text;
                        loc1 = true;
                    }
                    else 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(35532));
                    }
                }
                else 
                {
                    MsgManager.showRollTipsMsg(Language.getString(35531));
                }
            }
            else 
            {
                MsgManager.showRollTipsMsg(Language.getString(35528));
            }
            return loc1;
        }

        public setTipsOneTxt(): void
        {
            this._tips1Txt.htmlText = Language.getString(35533);
            return;
        }

        public resetSprite(): void
        {
            this._firstPwTxt.text = "";
            this._secondPwTxt.text = "";
            return;
        }

        public numberKeyboardChange(arg1: string): void
        {
            var loc1=this._focusInTxt.text.length;
            if (arg1 != "←") 
            {
                if (arg1 != "C") 
                {
                    this._focusInTxt.text = this._focusInTxt.text.concat(arg1);
                }
                else 
                {
                    this._focusInTxt.text = "";
                }
            }
            else 
            {
                this._focusInTxt.text = this._focusInTxt.text.slice(0, (loc1 - 1));
            }
            return;
        }

        /* internal */ /* var */_firstPwTxt: GTextInput;

        /* internal */ /* var */_secondPwTxt: GTextInput;

        /* internal */ /* var */_tips1Txt: Object /* flash.text.TextField */;

        /* internal */ /* var */_focusInTxt: GTextInput;
    }
